package gsar.client;

/*
Copyright (c) 2009, Eric Eaton, University of Maryland Baltimore County
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the University of Maryland Baltimore County nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/** Describes an object in the gridworld.
 *
 * @author Eric Eaton
 */
public class GWObject {

	/** The object's coordinates */
	private GWCoordinate m_coordinates;
	
	/** The name of the object */
	private String m_name = null;
	
	/** A list of feature describing the object */
	private Object[] m_description = null;

	/** Constructor for an object without a description.
	 * @param name the name of the object
	 * @param coords the location of the object
	 */
	public GWObject(String name, GWCoordinate coords) {
		if (name == null || name.length() == 0) {
			throw new IllegalArgumentException("name cannot be null or empty.");
		}
		if (coords == null) {
			throw new IllegalArgumentException("coords cannot be null.");
		}
		m_name = name;
		m_coordinates = coords;
	}
	
	/** Constructor for an object with a description.
	 * @param name the name of the object
	 * @param coords the location of the object
	 * @param description the feature-vector description of the object
	 */
	public GWObject(String name, GWCoordinate coords, Object[] description) {
		this(name,coords);
		m_description = description;
	}
	
	/** Gets the name of the object.
	 * @return the name of the object
	 */
	public String getName() {
		return m_name;
	}

	
	/** Gets the current location of the object.
	 * @return the current location of the object.
	 */
	public GWCoordinate getCoordinates() { return m_coordinates; }
	
	
	/** Gets the representation of the object as a feature vector.
	 * @return the representation of the object as a feature vector.
	 */
	public Object[] getDescription() {
		return m_description;
	}
	
	
	public String toString() {
		String str = getClass().getName()+" "+m_name+" at "+m_coordinates;
		if (m_description != null) {
			str += " [ ";
			for (Object o : m_description)
				str += o + " ";
			str += "]";
		}
		return str;
	}
}
